package engine.newUi
{
	
	import engine.data.BindManage;
	import engine.data.ModelLocator;
	import engine.data.ObjectData;
	import engine.data.ResPath;
	import engine.data.RoleVo;
	import engine.data.Scene;
	import engine.data.View;
	import engine.data.ViewObject;
	import engine.flag.GameDefine;
	import engine.flag.ResourcesPath;
	import engine.logic.DieHelpLogic;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.tip.TipsMainLogic;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.utils.getQualifiedClassName;
	
	import newx.com.config.StaticIni;
	import newx.com.control.NxClip;
	import newx.com.control.button.NxButton;
	import newx.com.control.tab.NxTab;
	import newx.com.control.tab.NxTabEvent;
	import newx.com.control.window.NxWindowEvent;
	import newx.utils.FilterUtil;

	/**
	 *伙伴邀请 
	 * @author yanghr
	 * 
	 */	
	public class PartnerInviteLogic
	{
		private static var _ui:PartnerInviteUI;
		private static var _self:PartnerInviteLogic;
		
		/**
		 *一页显示单元最大数 
		 */		
		private var MAX_ONE_PAGE:int=12;
		/**
		 * 		PART_NAME	伙伴名字   
		 *		PART_GANG	伙伴门派
		 *		PART_TASK	主线任务需求
		 *		PART_MONEY	货币需求
		 * 		PART_NEED_LEVEL 伙伴邀请等级(也是声望等级)
		 * 		PART_HEAD	伙伴头像
		 * 		PART_COMMEND	是否推荐（1,0）
		 * 		PART_HALF	半身像
		 * 		PART_CONFIG_ID	id
		 * 		PART_SKILL:String	技能
		 *		PART_SKILL_DES:		技能描述
		 *		PART_HP:String		生命
		 *		PART_MAXHP:String	,最大生命
		 *		PART_ING:String		内功
		 *		PART_STA:String		体质
		 *		PART_STR:String		外功
		 * 		PART_PEER:String	声望
		 * 		PART_LEVEL:String		等级
		 */
		private const PART_NAME:String		=	"nname",
						PART_GANG:String	=	"ProfType",
						PART_TASK:String	=	"NeedTaskID",
						PART_MONEY:String	=	"NeedGoldCoin",
						PART_NEED_LEVEL:String	=	"PartnerInviteLevel",
						PART_HEAD:String	=	"Model",
						PART_COMMEND:String	=	"NeedRecommend",
						PART_HALF:String	=	"Model",
						PART_CONFIG_ID:String	=	"ConfigID",
						PART_SKILL:String	=	"DefaultUltraSkill",
						PART_SKILL_DES:String	=	"skill_dest",
						PART_HP:String		=	"HP",
						PART_MAXHP:String	=	"MaxHP",
						PART_ING:String		=	"Ing",
						PART_STA:String		=	"Sta",
						PART_STR:String		=	"Str",
						PART_PEER:String	=	"NeedRepute",
						PART_LEVEL:String	=	ActorPropertyUI.LEVEL;
		/**
		 *group属性 .......................
		 */
		/**
		 *头像NXCLIP 
		 */		
		private const IMG:String	=	"img";
		/**
		 *固有属性 
		 */		
		private const BG:String	=	"p_mc";
		private const NAME:String	=	"titleTxt";
		private const LVL:String	=	"infoTxt";
		private const BTN:String	=	"bt_mc";
		private const BTN_LAB:String=	"btntxt";
		private const BACK_COLOR:String	=	"dt_mc";
		private const CONTAINER:String		=	"img01";
		private const RECOMMEND:String		=	"tj_mc";
		/**
		 *数据 
		 */		
		private const INDEX:String	=	"index";
		private const DATA:String	=	"dataIt"
		
		/**
		 *三个特殊标签 标识符 
		 * 数据在_partnerRaces
		 * 同时也是位置索引
		 * 跟TAB_MAP关联
		 */		
		private const ARR_ALL:String="all",
						ARR_COMMEND:String="commend",
						ARR_BACK_TEAM:String="back_team",
						ARR_RACE:String="race_arr",
						ARR_ARR:Array=[ARR_ALL,ARR_COMMEND,ARR_BACK_TEAM];
		
		private const APPLY_STR:String	=	"UIString_1000030",
						COME_BACK_STR:String="UIString_1000024";
		//		private const 
		/**
		 *mc[BACK_COLOR]背景状态 frame
		 * NORMAL_STATE:int	=	普通状态
		 * ROLL_STATE:int	=	移在上面的状态
		 * CLICK_STATE:int	=	点击状态
		 * DISABLE_STATE:int	不能用状态
		 */		
		private const NORMAL_STATE:int	=	1,
						 ROLL_STATE:int	=	2,
						 CLICK_STATE:int	=	3,
						 DISABLE_STATE:int	=	4;
		/**
		 *种类标签 
		 */	
		private const TAB_ARR:Array=["UIString_1000022","UIString_1000023","UIString_1000024"],
						RACE_ARR:Array=[1,2,3,4,5]
					;
		private var 	TAB_MAP:Object={};
		
		//资源域名前缀
		private const PARTNER:String="21001001"
		
		private var _bindFlag:int	=	-1;
		private var _bindAwayFlag:int	=	-1;
		private var _bindPeerFlag:int=-1;
		private var _bindMoneyFlag:int=	-1;
		private var _bindAcceptFlag:int=	-1;
		private var _bindFinishRec:int=	-1;
		private var _bindLvlFlag:int	=	-1;
		private var _needRefreshTab:Boolean	=	false;
		private var _hasPartnerInvite:Boolean=false;
		
		private var _model:ModelLocator;
		private var _scene:Scene;
		private var _role:RoleVo;
		private var _tips:TipsMainLogic;
		private var _bind:BindManage
		private var _roll_cell:MovieClip;
		private var _selectEdMovip:MovieClip;
		/**
		 * 
		 *当前标签数据 
		 */		
		private var _currentArr:Array;
		/**
		 *当前页数据 
		 */		
		private var _currPageArr:Array;
		
		private var _partnerRaces:Array;
		private var _currentTable:Object=new Object;
		
		private var _currentAcceptTable:Object
		private var _currentAcceptPartner:Object=new Object;
		

		
		private var _nowPartnerArr:Array	=	[];
		/**
		 *储存当前删除的配置 
		 */		
		private var _nowConfdata:Object	=	new Object();
		private var _maxCount:int	=	10;
		private var _nowCount:int;
		
		private var _maxPage:int	;
		private var _currentPage:int=1;
		
		private var _des_Y:Number;
		private var _bindInitFlag:Boolean=false;
		private var _shownameMap:Object={};
		
		public static function getInstance():PartnerInviteLogic
		{
			if(_self==null)
			{
				_self=new PartnerInviteLogic();
			}
			return _self;
		}
		public function get ui():PartnerInviteUI
		{
			if(_ui==null)
			{
				_ui=new PartnerInviteUI()
			}
			return _ui;
		}
		public function Init():void
		{
			_model=ModelLocator.getInstance();
			_scene=_model.scene;
			_role=_scene.Role;
			_tips=TipsMainLogic.instance;
			_bind=BindManage.getInstance();
			_partnerRaces=[];
//			_ui.visualClip.scaleX=_ui.visualClip.scaleY=0.7;
//			_ui.visualClip.height = _ui.visualClip.height = 30;
			MAX_ONE_PAGE=ui.partnerGroup.col*ui.partnerGroup.row;
			for (var i:int = 0; i < MAX_ONE_PAGE; i++) 
			{
				var mc:MovieClip=ui.partnerGroup.getItemByIndex(i);
				mc[INDEX]=i;
				mc[IMG]=new NxClip();
				mc[IMG].isCache = true;
//				mc[BG][CONTAINER].addChild(mc[IMG]);
				mc.addChild(mc[IMG])
				var p:Point=new Point(mc[BG][CONTAINER].x,mc[BG][CONTAINER].y);
				p=mc.globalToLocal((mc[BG][CONTAINER].parent as DisplayObjectContainer).localToGlobal(p));
				mc[IMG].x=p.x;
				mc[IMG].y=p.y;
//				mc[BTN_LAB].mouseEnabled=false
				(mc[BTN_LAB] as TextField).multiline=false;
				(mc[BTN_LAB] as TextField).wordWrap=false;
				(mc[BTN_LAB] as TextField).autoSize=TextFieldAutoSize.CENTER;
//				mc[BTN]=//transFromSkinToBtn(mc["bt_mc"]);
//				mc[NAME]=new NxLabel();
//				mc.addChild(mc[NAME]);
			}
			refreshCount();
			ui.windowBG.title = StaticIni.getSwfLangStr( "UIString_1000019");
			var tt:TextField=ui.currentCountLab.textField;
			tt.wordWrap=true;
			tt.width=250;
			_des_Y	=	ui.bg2.y+ui.bg2.height	-10;
			nowPartnerCount++;
//			(_ui.bg13 as NxClip).source=ResPath.JPG+"partnerBG.jpg";
			_ui.applyBtn.visible=false;
			_shownameMap[PART_NEED_LEVEL]="UIString_1000444";
			_shownameMap[PART_PEER]="UIString_1000444";
			_shownameMap[PART_MONEY]="UIString_1000445";
		}
		public function transFromSkinToBtn(skin:DisplayObject):NxButton
		{
			var str:String=getQualifiedClassName(skin);
			var bt:NxButton=new NxButton();
			bt.skin=str;
//			ui.windowBG.addChild(bt);
			var wid:Number	=	skin.width;
			var hei:Number	=	skin.height;
			var xx:Number	=	skin.x;
			var yy:Number	=	skin.y;
			bt.width	=	wid;
//			bt.width=	81
			bt.height	=	hei;
			bt.x		=	xx;
			bt.y		=	yy;
			if(skin.parent)
			{
				var skinParent:DisplayObjectContainer	=	skin.parent;
				var deepIndex:int		=	skinParent.getChildIndex(skin)
				skinParent.removeChild(skin);
				skinParent.addChildAt(bt,deepIndex);
			}
			return bt;
		}
		private var bind_temp:Boolean=false;
		private function initAccept():void
		{
			if(_currentAcceptTable)return;
			_currentAcceptTable=StaticIni.getIniObj("PartnerInvite_SPecial");
			for (var i:String in _currentAcceptTable) 
			{
				_currentAcceptPartner[_currentAcceptTable[i]]=i;
			}
			
		}
		public function BeforeShow():void
		{
//			if(!(_ui.bg13 as NxClip).content)
//			{
				(_ui.bg13 as NxClip).source=ResPath.JPG+"partnerBG.jpg";
				initAccept();
//			}
			_bindInitFlag=true;
			bind_temp=false;
			if(!_partnerRaces||!_partnerRaces.length)
			{
				ransackPartner();
				sortAllPartners();
//				_currentArr=
//				refreshIndex(ui.raceTab.selected);
				refreshTab();
				_currentArr=_partnerRaces[ARR_ALL];
				addAllListener()
				ui.raceTab.selected=0;
//				refreshIndex()
			}
			else
			{
				ransackCurrData();
				addAllListener();
				if(	_needRefreshTab)
				{
					refreshTab()
				}
				_needRefreshTab=false;
				refreshIndex()
			}
			bind_temp=true;
//			_ui.windowBG.title="伙伴邀请"
		}
		private function refreshTab():void
		{
			ui.raceTab.clearItems();
			for (var i:int = 0; i < RACE_ARR.length+TAB_ARR.length; i++) 
			{
				var indexxx:*=(getArrProperty(i))
				if((!_partnerRaces[indexxx]||!_partnerRaces[indexxx].length)&&i>=3)
				{
					continue;
				}
				else
				{
					if(i<TAB_ARR.length)
					{
						if(_partnerRaces[indexxx]==null)
						{
							_partnerRaces[indexxx]=[];
							
						}
						//取消掉  推荐   如果以后要加回来  取消掉这句判断
						if(i!=ARR_ARR.indexOf(ARR_COMMEND))
						{
							TAB_MAP[ARR_ARR[i]]=ui.raceTab.count;
							ui.raceTab.addItem(StaticIni.getSwfLangStr(TAB_ARR[i]),-1,_partnerRaces[indexxx]);
						}
					}
					else
					{
//						trace("PartnerInviteLogic.refreshTab()",indexxx,GameDefine.PART_PROFTYPE(RACE_ARR[i-TAB_ARR.length]));
						_currentTable[indexxx]=ui.raceTab.count;
						ui.raceTab.addItem(GameDefine.PART_PROFTYPE(RACE_ARR[i-TAB_ARR.length-1]),-1,_partnerRaces[indexxx])
					}
				}
			}
//			ui.raceTab.up
			ui.raceTab.selected=0;
		}
		private function onClickClose(e:Event):void
		{
			_ui.hide();
		}
		public function addAllListener():void
		{
			ui.raceTab.addEventListener(NxTabEvent.TAB_CLICK,raceClickHandle);
//			ui.pageTab.addEventListener(NxTabEvent.TAB_CLICK,raceClickHandle);
			ui.arrow_left.addEventListener(MouseEvent.CLICK,pageClickHandle);
			ui.arrow_right.addEventListener(MouseEvent.CLICK,pageClickHandle);
			ui.applyBtn.addEventListener(MouseEvent.CLICK,applyClickHandle);
			ui.partnerGroup.addItemsEvent(MouseEvent.CLICK,groupClickHandle);
			ui.partnerGroup.addItemsEvent(MouseEvent.ROLL_OVER,rollOver);
			ui.partnerGroup.addItemsEvent(MouseEvent.ROLL_OUT,rollOut)
//			ui.exitBtn.addEventListener(MouseEvent.CLICK,onClickClose);
//			ui.actorBtn.addEventListener(MouseEvent.CLICK,actorHandle)
			ui.windowBG.addEventListener(NxWindowEvent.WINDOW_CLOSE,		onClickClose);
			if( _bindFlag == -1 )
			{
//				trace("PartnerInviteLogic.addAllListener()","绑定视图伙伴");
				_bindFlag		=	_bind.BindView(_model.scene,View.VIEWPORT_PARTNER,OnAddPartner,OnRemovePartner);
			}
			if(_bindAwayFlag==-1)
			{
				_bindAwayFlag		=	_bind.BindView(_model.scene,View.VIEWPORT_RETIRE_PARTNER,OnAddRetirePartner,OnRemoveRetirePartner);				
			}
			if(_bindMoneyFlag==-1)
			{
				_bindMoneyFlag		=	_bind.BindProp(_role,"GoldCoin",this,"money");				
			}
			if(_bindPeerFlag==-1)
			{
				_bindPeerFlag		=	_bind.BindProp(_role,"Repute",this,"peerCount");				
			}
			if(_bindFinishRec==-1)
			{
				_bindFinishRec	=	_bind.BindRecord(_model.scene,"Task_Completed",onaddPerHandle,onremovePerHandle);
			}
			if(_bindAcceptFlag==-1)
			{
				_bindAcceptFlag	=	_bind.BindRecord(_model.scene,"Task_Accepted",onaddTaskAccept,null);
			}
			if(_bindLvlFlag==-1)
			{
				_bindLvlFlag		=	_bind.BindProp(_role,ActorPropertyUI.PARTNER_INVITE,this,"resetLevel");				
			}
		}
		private function onaddTaskAccept(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
//			trace("PartnerInviteLogic.onaddTaskAccept(PropertiesName, PropertiesValue, data)",PropertiesName,PropertiesValue);
//			_currentAcceptTable[PropertiesValue[0]]=PropertiesValue[1];
			var taskID:int=PropertiesValue[0];
			if(_currentAcceptTable.hasOwnProperty(taskID))
			{
				var partnerId:int=_currentAcceptTable[taskID];
				var b:Boolean=_nowPartnerArr.some(	function arrfilterClosure(item:ObjectData,index:int,arr:Array):Boolean
				{
					if(item)
					return item.GetPropertiesEx(ActorPropertyUI.CONFIG_ID)==partnerId;
					return false;
				})
				if(b)return ;
				addPartner(_nowConfdata[partnerId]);
				_needRefreshTab=true;
			}
		}
		/**
		 *	 *	添加
		 *	[0]
		 * [1]
		 * [2]  
		 * @param PropertiesName
		 * @param PropertiesValue
		 * @param data
		 * 
		 */		
		private function onaddPerHandle(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
//			trace("PartnerInviteLogic.onaddPerHandle(PropertiesName, PropertiesValue, data)",PropertiesName,PropertiesValue);
			reSetAll()
		}
		public function set resetLevel(value:int):void
		{
			reSetAll()
		}
		private function reSetAll():void
		{
			if(bind_temp)
			{
				bind_temp	=	false;
				removeAllListener();
				_partnerRaces=[];
				BeforeShow();
			}
		}
		private function onremovePerHandle(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
//			trace("Error~PartnerInviteLogic.onremovePerHandle(PropertiesName, PropertiesValue, data)","删除已经完成的任务？？");
			
		}
		public function set peerCount(value:int):void
		{
			ui.Text1.htmlText=StaticIni.getSwfLangStrVar("UIString_1000017",[value])
		}
		public function set money(val:int):void
		{
			ui.Text2.htmlText=StaticIni.getSwfLangStrVar("UIString_1000026",[val]);
		}
		public function AfterHide():void
		{
			nowPartnerCount=1
			_nowPartnerArr=[];
//			_partnerRaces=[];
			removeAllListener();
			_bindInitFlag=false;
		}
		public function removeAllListener():void
		{
			ui.raceTab.removeEventListener(NxTabEvent.TAB_CLICK,raceClickHandle);
//			ui.pageTab.removeEventListener(NxTabEvent.TAB_CLICK,raceClickHandle);
			ui.arrow_left.removeEventListener(MouseEvent.CLICK,pageClickHandle);
			ui.arrow_right.removeEventListener(MouseEvent.CLICK,pageClickHandle);
			ui.applyBtn.removeEventListener(MouseEvent.CLICK,applyClickHandle)
			ui.windowBG.removeEventListener(NxWindowEvent.WINDOW_CLOSE,		onClickClose);
			ui.partnerGroup.removeItemsEvent(MouseEvent.CLICK,groupClickHandle)
			ui.partnerGroup.removeItemsEvent(MouseEvent.ROLL_OVER,rollOver);
			ui.partnerGroup.removeItemsEvent(MouseEvent.ROLL_OUT,rollOut)
//			ui.exitBtn.removeEventListener(MouseEvent.CLICK,onClickClose)
//			ui.actorBtn.removeEventListener(MouseEvent.CLICK,actorHandle)
			if( _bindFlag != -1 )
			{
				_bindFlag		=	_bind.UnbindView(View.VIEWPORT_PARTNER,_bindFlag);
			}
			if(_bindAwayFlag!=-1)
			{
				_bindAwayFlag		=	_bind.UnbindView(View.VIEWPORT_RETIRE_PARTNER,_bindAwayFlag);				
			}
			if(_bindMoneyFlag!=-1)
			{
				_bindMoneyFlag		=	_bind.UnbindProp(_role,"GoldCoin",_bindMoneyFlag);				
			}
			if(_bindPeerFlag!=-1)
			{
				_bindPeerFlag		=	_bind.UnbindProp(_role,"Repute",_bindPeerFlag);				
			}
			if(_bindFinishRec!=-1)
			{
				_bindFinishRec	=	_bind.UnbindRecord("Task_Completed",_bindFinishRec);
			}
			if(_bindAcceptFlag!=-1)
			{
				_bindAcceptFlag	=	_bind.UnbindRecord("Task_Accepted",_bindAcceptFlag);
			}
			if(_bindLvlFlag!=-1)
			{
				_bindLvlFlag		=	_bind.UnbindProp(_role,ActorPropertyUI.PARTNER_INVITE,_bindLvlFlag);				
			}
		}
		
		public function set rollCell(value:MovieClip):void
		{
			if(_roll_cell	&&	_roll_cell.currentFrame!=CLICK_STATE)
				_roll_cell.gotoAndStop(NORMAL_STATE)
			_roll_cell=value;
			if(_roll_cell	&&	_roll_cell.currentFrame!=CLICK_STATE)
				_roll_cell.gotoAndStop(ROLL_STATE)
		}
		private function rollOver(e:Event):void
		{
			var mc:MovieClip=e.currentTarget as MovieClip;
			rollCell=mc[BACK_COLOR]
//			var tipsitem:*=;
//			tipsitem.data=mc[DATA];
			_tips.showByItem(_tips.getPartnerItem(null,mc[DATA]));
		}
		private function rollOut(e:Event):void
		{
			var mc:MovieClip=e.currentTarget as MovieClip;
			rollCell=null
			_tips.hide();
		}
		private function actorHandle(e:Event):void
		{
			MyPropertyLogic.getInstance().ui.showOrHide();
		}
		public function get checkGuide():int
		{
			if(hasPartnerInvite)//如果有未招募伙伴，提示招募伙伴；      
			{
				return DieHelpLogic.BUDDY;
			}
			if(MyPropertyLogic.getInstance().isPartnerNotEmbattle)//	如果招募了伙伴但没有布阵，提示布阵；
			{
				return DieHelpLogic.EMBATTLE;
			}
			return -1;
		}
		private function clearLeftPanel():void
		{
			ui.visualClip.source=null;
			ui.visualClip.clear();
			ui.costLab.htmlStr	=	"";
			ui.currentCountLab.htmlStr	=	"";
			ui.baseAttrLab.htmlStr="";
			ui.detailAttrLab.htmlStr="";
			ui.bg8.visible=false;
		}
		private function groupClickHandle(e:MouseEvent):void
		{
			if(_selectEdMovip)
			{
//				_selectEdMovip.selected=false;
				_selectEdMovip[BACK_COLOR].gotoAndStop(NORMAL_STATE);
			}
			_selectEdMovip=e.currentTarget as MovieClip;
//			_selectEdMovip.selected=true;
			_selectEdMovip[BACK_COLOR].gotoAndStop(CLICK_STATE);
			var obj:Object=_selectEdMovip[DATA];
			//设置半身像
			if(obj)
			{
				ui.bg8.visible=true;
				ui.visualClip.source=ResourcesPath.getMiniHeadPic(obj[PART_HALF]);
				//按钮
				refreshBtn(_selectEdMovip[DATA],ui.applyBtn);
				//设置文本信息
	//			_partnerInfo.tipsObj=TipsMainLogic.instance.combiObj(_selectEdMovip[DATA]);
				var plist:Array=[];
	//			plist.push(StaticIni.getSwfLangStr(objTranfer(obj[PART_CONFIG_ID])));
	//			plist.push(objTranfer(obj[PART_LEVEL]));
	//			plist.push(objTranfer(
	//				GameDefine.PART_GANG(obj[PART_GANG]
	//				)));
	//			plist.push(StaticIni.getSwfLangStr(objTranfer(obj[PART_SKILL])));
	//			plist.push(GameDefine.GET_SKILL_DES(int(objTranfer(obj[PART_SKILL]))));
	//			if(obj[PART_HP])
	//				plist.push(objTranfer(obj[PART_HP]));
	//			else
	//				plist.push(objTranfer(obj[PART_MAXHP]));
	//			plist.push(objTranfer(obj[PART_MAXHP]));
	//			plist.push(objTranfer(obj[PART_STA]));
	//			plist.push(objTranfer(obj[PART_STR]));
	//			plist.push(objTranfer(obj[PART_ING]));
	//			ui.currentCountLab.htmlStr=StaticIni.getSwfLangStrVar("stringpartner_001",plist);
				
//				ui.currentCountLab.htmlStrByBorder=StaticIni.getSwfLangStr("Des_"+objTranfer(obj[PART_CONFIG_ID]));
				
	//			plist=[];
				plist.push(objTranfer(getColor(obj[PART_MONEY],_role.getGoldCoin())));
				plist.push(objTranfer(getColor(obj[PART_PEER],_role.GetPropertiesEx("Repute"))));
				plist.push(objTranfer(getColor(obj[PART_NEED_LEVEL],_role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE))))
				ui.costLab.htmlStrByBorder=StaticIni.getSwfLangStrVar("stringinvite_001",plist);
				plist=[];
				plist.push(StaticIni.getSwfLangStr(objTranfer(obj[PART_CONFIG_ID])));
				plist.push(StaticIni.getSwfLangStr("PartnerInviteLevel_"+objTranfer(
					(obj[PART_NEED_LEVEL])
					)));
				plist.push(objTranfer(
									GameDefine.PART_PROFTYPE(obj[PART_GANG]
									)));
				ui.baseAttrLab.htmlText=StaticIni.getSwfLangStrVar("UIString_1000442",plist);
				plist=[];
				var mxHp:String=DetailPropertyLogic.getInstance().setData(obj).maxlife;
				plist.push(objTranfer(/*obj.hasOwnProperty(PART_HP)?obj[PART_HP]:*/mxHp));
				plist.push(objTranfer(obj[PART_STR]));
				plist.push(objTranfer(obj[PART_ING]));
				plist.push(objTranfer(obj[PART_STA]));
				var  s:String=StaticIni.getSwfLangStr(objTranfer(obj[PART_SKILL]));
				plist.push(s)
				plist.push(changeLine(GameDefine.GET_SKILL_DES(int(objTranfer(obj[PART_SKILL]))),s.length));
				ui.detailAttrLab.htmlText=StaticIni.getSwfLangStrVar("UIString_1000443",plist);
//				UIString_1000443	*生命<font color='#ff8000'>{@0:生命}</font><br/>外功<font color='#ff8000'>{@1:外功}</font><br/>内功<font color='#ff8000'>{@2:内功}</font><br/>体魄<font color='#ff8000'>{@3:体魄}</font><br/>技能<font color='#ff8000
//					戚震昊(戚震昊) 11:04:00				'>{@4:技能及描述}

			}
			else
			{
				clearLeftPanel();
			}
			ui.currentCountLab.y=_des_Y-_ui.currentCountLab.textField.textHeight;
			if(e.target == _selectEdMovip[BTN_LAB]&&_selectEdMovip.enabled/*|| _selectEdMovip[BTN].contains(e.target)*/)
			{
//				trace("PartnerInviteLogic.groupClickHandle(e)",_selectEdMovip[BTN].enabled);
				applyClickHandle(e);
			}
			function changeLine(str:String,strLen:int=0):String
			{
				return str;
				const len:int=13;
				if(str.length+strLen<len)
				{
					return str;
				}
				var stt:String=str.substr(0,len-strLen)+"\n"+changeLine(str.substr(len-strLen),-2)
				return stt;
			}
			function getColor(needcount:int,nowCount:int):String
			{
				return _tips.getColorHtml(needcount+"",needcount>nowCount?"ff0000":"")
			}
		}
		private function objTranfer(obj:*):String
		{
			if(!obj)
			return 0+""
			return obj;
		}
		private function getPartnerInfo(index:int):Object
		{
			var obj:*=_tips.getStaticObjWithID(index+"")//StaticIni.getIniObj(index+"");
				//StaticIni.getSwfLangStr(PARTNER+index);
			if(obj)
			{
				obj[PART_CONFIG_ID]	=	index;
				obj[PART_MAXHP]=GameDefine.GET_MAXHP(obj[PART_STA],obj[PART_LEVEL]);
			}
			return obj;
		}
		private function sortAllPartners():void
		{
			for each (var i:Array in _partnerRaces) 
			{
				sortPartner(i);
			}
			sortPartner(_partnerRaces[ARR_ALL])
			sortPartner(_partnerRaces[ARR_COMMEND])
			sortPartner(_partnerRaces[ARR_BACK_TEAM])
			
		}
		private function sortPartner(partners:Array):void
		{
			if(partners)
				partners.sort(compare);
			function compare(a:Object,b:Object):Number
			{
//				按声望等级来排呗
				if(a[PART_NEED_LEVEL]!=b[PART_NEED_LEVEL])
					return b[PART_NEED_LEVEL]-a[PART_NEED_LEVEL]
//				相同声望等级就按职业顺序排下好了
				return a[PART_GANG]-b[PART_GANG];
			}
		}
		private function ransackCurrData():void
		{
			for each (var i:Object in _nowConfdata) 
			{
				setPartner(i);
			}
			
		}
		/**
		 *遍历 伙伴配置 
		 * 
		 */		
		private function ransackPartner():void
		{
			var tArr:Object;
			var i:int=int(PARTNER);
			do
			{
				tArr=getPartnerInfo(i);
				i++;
//				trace("PartnerInviteLogic.ransackPartner()",i);
			setPartner(tArr);
			}while(tArr!=null)
//			refreshIndex();
		}
		/**
		 * 读取配置文件设置
		 * @param arr			 数组结构如：getPartnerInfo
		 * @param needrefresh	是否马上刷新显示
		 * @see getPartnerInfo
		 */		
		private function setPartner(arr:Object):void
		{
//			trace("PartnerInviteLogic.setPartner(arr, needrefresh)");
			if(arr)
			{
				var index:int=arr[PART_GANG];
//				if(ii)
//					index=	transferGangToTabIndex(ii)
//				else
//					index=0;
//				trace("PartnerInviteLogic.setPartner(arr)",ii,index);
				if(!showCondition(arr))
				{
//					_notInPartnerMap[]=arr;
					_nowConfdata[arr[PART_CONFIG_ID]]=arr
//					trace("PartnerInviteLogic.setPartner(arr)~~~~~~~~~NOt");
					return 
				}
				addPartner(arr);
				
//				if((ui.raceTab.selected	==	index|| ui.raceTab.selected	==	0)	)
//				{
//					refreshIndex(ui.raceTab.selected);
//				}
			}
		}
		private function addPartner(objPartner:Object):void
		{
			if(!objPartner)return ;
			var index:int=objPartner[PART_GANG]
			if(_nowConfdata.hasOwnProperty(objPartner[PART_CONFIG_ID]))
			{
				delete _nowConfdata[objPartner[PART_CONFIG_ID]];
			}
			if(!_partnerRaces[index])
			{
				_partnerRaces[index]	=	[];
				_needRefreshTab=true
			}
			if(!_partnerRaces[ARR_ALL])
			{
				_partnerRaces[ARR_ALL]		=	[];
			}
			if(Boolean(int(objPartner[PART_COMMEND])))
			{
				if(!_partnerRaces[ARR_COMMEND])
				{
					_partnerRaces[ARR_COMMEND]=[];
				}
				if(	_partnerRaces[ARR_COMMEND].indexOf(objPartner)==-1)
					_partnerRaces[ARR_COMMEND].push(objPartner);
				objPartner[ARR_COMMEND]=_partnerRaces[ARR_COMMEND].length-1;
			}
			if(	_partnerRaces[index].indexOf(objPartner)==-1)
				_partnerRaces[index].push(objPartner);
			if(	_partnerRaces[ARR_ALL].indexOf(objPartner)==-1)
				_partnerRaces[ARR_ALL].push(objPartner);
		}
		/**
		 *显示条件 
		 * @return 
		 * 
		 */		
		private function showCondition(arr:Object):Boolean
		{
//			return true;
//			接受任务要求，屏蔽掉
			if(_currentAcceptPartner.hasOwnProperty(arr[PART_CONFIG_ID]))return false;
			var b:Boolean;
//			trace("PartnerInviteLogic.setPartner(arr)",arr["ConfigID"],arr[PART_TASK]);
			//主线任务需求
			if(arr[PART_TASK]	&&	arr[PART_TASK]!="0")
			{
				var arr2:Array=_scene.GetRecordEx("Task_Completed").recArr
				for each (var ia:Array in arr2) 
				{
					if(ia[0]==int(arr[PART_TASK]))
					{
						b=true;
						break;
					}
					else
					{
//						trace("PartnerInviteLogic.showCondition(arr)",StaticIni.getSwfLangStr(arr[PART_CONFIG_ID]));
					}
				}
				if(!b)
				{
//					trace("ia[0]=",ia[0],StaticIni.getSwfLangStr(arr[PART_CONFIG_ID]));
					return false;
				}
			}
			//伙伴等级需求
			var lvl:int=_role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE);
			if(arr[PART_NEED_LEVEL]>lvl+1)
			{
//				trace("PartnerInviteLogic.showCondition(arr)","PART_NEED_LEVEL",arr[PART_NEED_LEVEL]);
//				trace("22PartnerInviteLogic.showCondition(arr)",StaticIni.getSwfLangStr(arr[PART_CONFIG_ID]),arr[PART_NEED_LEVEL],lvl);
				return false;
			}
			return true;
				
		}
		/**
		 *能否申请 
		 * @return 
		 * 
		 */		
		private function applyCondition(arr:Object):String
		{
			var moneyNeed:int	=	arr[PART_MONEY]
			if(arr[PART_PEER]	> _role.GetPropertiesEx("Repute"))
				return PART_PEER;
			if(moneyNeed	>	_role.getGoldCoin())
				return PART_MONEY;
			if(arr[PART_NEED_LEVEL]>_role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE))
				return PART_NEED_LEVEL;
			return "";
		}
		private function applyClickHandle(e:MouseEvent):void
		{
			if( null == _selectEdMovip[DATA] )
			{
				return;
			}
			//邀 请xx加入
//			if(_nowCount<_maxCount)
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_INVITE_PARTNER,int(_selectEdMovip[DATA][PART_CONFIG_ID]));
		}
		private function raceClickHandle(e:NxTabEvent):void
		{
			_currentArr		=	e.item.data//_partnerRaces[getArrProperty(e.item.index,e.currentTarget as NxTab)];
//			ui.pageTab.clearItems();
			if(_currentArr&&_currentArr.length)
			{
				maxPage	=	Math.ceil(_currentArr.length/MAX_ONE_PAGE)
				currentPage	=	1;
				refreshPageTxt();
//				for (var i:int = 0; i < _currentArr.length/MAX_ONE_PAGE; i++) 
//				{
//					ui.pageTab.addItem((i+1)+"");
//				}
//				ui.pageTab.selected	=	0;
			}
			refreshIndex(0);
			ui.partnerGroup.getItemByIndex(0).dispatchEvent(new MouseEvent(MouseEvent.CLICK))
//			ui.pageTab.get
		}
		/**
		 *从门派得到到  index 
		 * @param gang
		 * @return 
		 * 
		 */		
		private function transferGangToTabIndex(gang:int):int
		{
//			return RACE_ARR.indexOf(gang)
//			trace("PartnerInviteLogic.transferGangToTabIndex(gang)",gang, _currentTable[gang],GameDefine.PART_PROFTYPE(gang));
			return _currentTable[gang]
		}
		private function getArrProperty(index:int,tab:NxTab=null):String
		{
//			if(tab==ui.raceTab)
//			{
////				ui.pageTab.selected=-1
//				return index+"";
//			}
			switch(index)
			{
				case 0:
				{
					return ARR_ALL
				}
				case 1:
				{
					return ARR_COMMEND
				}
				case 2:
				{
					return ARR_BACK_TEAM
				}		
				default:
				{
					return (index-3)+""
//					return index+""
					
				}
			}
		}
		/**
		 *刷新状态根据页数 计算当前页数据 
		 * @param page
		 * 
		 */		
		private function refreshIndex(page:int=-1):void
		{
			if(_currentArr	!=	null)
			{
				if(_currentArr.length>MAX_ONE_PAGE)
				{
					var startindex:int	=(_currentPage-1)*MAX_ONE_PAGE;
					_currPageArr	=_currentArr.slice(startindex,startindex+MAX_ONE_PAGE);
				}
				else
				{
					_currPageArr	=	_currentArr;
					currentPage=1;
					maxPage=1
				}
			}
			else
			{
				_currPageArr=null;
				currentPage=1;
				maxPage=1
			}
			refreshPageTxt();
			refreshGroup();
		}
		/**
		 *刷新当前页 
		 * 
		 */		
		private function refreshGroup():void
		{
			for (var i:int = 0; i < MAX_ONE_PAGE; i++) 
			{
				var mc:MovieClip=ui.partnerGroup.getItemByIndex(i);
				if(_currPageArr&&i<_currPageArr.length&&(_currPageArr[i]))
				{
					mc.visible	=	true;
					mc[NAME].htmlText=_currPageArr[i][PART_NAME]=StaticIni.getSwfLangStrVar("PlayerProperty_20",[StaticIni.getSwfLangStr(_currPageArr[i][PART_CONFIG_ID])]);
					if(_currentArr[i][PART_LEVEL])
						(mc[LVL]).htmlText=StaticIni.getSwfLangStrVar("PlayerProperty_19",[_currentArr[i][PART_LEVEL]]);
					else
						mc[LVL].htmlText=StaticIni.getSwfLangStrVar("PlayerProperty_19",[1]);						
					//设置按钮文本
					mc[IMG].source=ResourcesPath.getMiniHeadPic(_currPageArr[i][PART_HEAD]);
						//ResPath.JPG+_currPageArr[i][PART_HEAD]+".jpg";
					mc[RECOMMEND].visible=Boolean(int(_currPageArr[i][PART_COMMEND]));
					mc[BACK_COLOR].gotoAndStop(NORMAL_STATE);
					mc[DATA]=_currPageArr[i];
					refreshBtn(mc[DATA],mc[BTN_LAB])
//					mc[BTN].enabled	=	mc[BTN].label	==	StaticIni.getSwfLangStr(APPLY_STR)?applyCondition(_currPageArr[i]):true;
				}
				else
				{
					mc.visible	=	false;
					mc[DATA]=null;
				}
			}
			clearLeftPanel()
		}
		public function get hasPartnerInvite():Boolean
		{
			if(_bindInitFlag)
			return _hasPartnerInvite;
			BeforeShow()
			AfterHide()
			return _hasPartnerInvite;
		}
		private function refreshBtn(data:Object,btn:*):void
		{
			var target:Object;
			var propertyName:String;
			if(btn is NxButton)
			{
				target=btn;
				propertyName="label";
			}
			else if(btn is TextField)
			{
//				var mc:Sprite=btn.parent;
				target=btn;
				propertyName="htmlText";
			}
			if(_partnerRaces[ARR_BACK_TEAM]&&(_partnerRaces[ARR_BACK_TEAM] as Array).indexOf(data)>-1)
			{
				target[propertyName]	=	_tips.getUnderLineHtml(StaticIni.getSwfLangStr(COME_BACK_STR),"d");
				if(!(btn is TextField))
					btn.enabled	=	true
				else
					btn.parent.enabled	=	true
			}
			else
			{
				var str:String=	applyCondition(data);
				if(btn is TextField)
				{
					var mc:MovieClip=btn.parent;
					if(!str)//满足条件
					{
						target[propertyName]	=	_tips.getUnderLineHtml(StaticIni.getSwfLangStr(APPLY_STR),"d");
					}
					else
					{
						target[propertyName]	=	StaticIni.getSwfLangStr(_shownameMap[str]);
					}
					mc.enabled=!str
				}
				else
				{
					target.enabled	=	!str;
				}
			}
			if(!(btn is TextField)&&btn.enabled)
				_hasPartnerInvite=true
			if(btn is SimpleButton)
			{
				if(btn.enabled==false)
				{
					(btn as DisplayObject).filters=[FilterUtil.GrayColorFilter]
				}
				else
				{
					(btn as DisplayObject).filters=null;
				}
			}
		}
//		public function set maxPartnerCount(value:String):void 
//		{
//			_maxCount	=	value;
//			refreshCount();
//		}
		public function get nowPartnerCount():int
		{
			return _nowCount;
		}
		public function set nowPartnerCount(value:int):void 
		{
			_nowCount	=	value;
			refreshCount()
		}
		public function set maxPage(value:int):void 
		{
			_maxPage=value;
		}
		public function set currentPage(value:int):void 
		{
			_currentPage=value;
		}
		private function refreshPageTxt():void
		{
			_currentPage=Math.min(_currentPage,_maxPage);
			ui.page_lab.text=_currentPage+"/"+_maxPage;
		}
		private function refreshCount():void
		{
			ui.Text3.htmlStr	=	StaticIni.getSwfLangStrVar("UIString_1000025",[_nowCount,_maxCount])//+_nowCount+"/"+
		}
		private function pageClickHandle(e:Event):void
		{
//			trace("PartnerInviteLogic.pageClickHandle(e)",e.target);
//			refreshIndex(e.item.index);
			if(e.target	==	ui.arrow_left)
			{
				//向左翻页
				if(_currentPage	==	1)return ;
				refreshIndex(--_currentPage);
			}
			else if(e.target	==	ui.arrow_right)
			{
				//向右翻页
				if(_currentPage	==	_maxPage)return ;
				refreshIndex(++_currentPage);
			}
			refreshPageTxt();
		}
		/**
		 *仅仅用于归队 
		 * @param PropertiesName
		 * @param PropertiesValue
		 * @param data
		 * 
		 */		
		private function OnAddRetirePartner(PropertiesName:String,PropertiesValue:ViewObject,data:*):void
		{
			var id:int	=	PropertiesValue.GetPropertiesEx("ConfigID");
			var targetObj:Object;
			if(_partnerRaces[ARR_BACK_TEAM])
			{
				var targetARr:Array		=	findSameConfigId(PropertiesValue,_partnerRaces[ARR_BACK_TEAM]);
				if(targetARr.length>0)
				{
					targetObj=targetARr[0];
					addALl();
					return 
				}
			}
			targetObj	=	_nowConfdata[id];
			if(targetObj)
			{
				delete 	_nowConfdata[id]
			}
			else
			{
				var allArr:Array=_partnerRaces[ARR_ALL];
				targetARr		=	findSameConfigId(PropertiesValue,allArr);
				targetObj=targetARr[0]
//					var ind:int=allArr.indexOf(i)
//					allArr.splice(ind,1);
//					_nowConfdata[i[PART_CONFIG_ID]]=i;
					//				 i[ARR_ALL]=ind;
			}
				targetObj=combiObj(PropertiesValue,targetObj);
			var arr:Array	=	_partnerRaces[ARR_BACK_TEAM];
			if(!arr)
			{
				arr	=	_partnerRaces[ARR_BACK_TEAM]	=	[];
			}
			var index:int	=	/*int(PropertiesName)*/arr.length-1;
			add(arr);
			if(!bind_temp)
				addALl();
			if(ui.raceTab.selected	==	transferGangToTabIndex(PropertiesValue.GetPropertiesEx(PART_GANG))||ui.raceTab.selected	==		(TAB_MAP[ARR_ALL])||ui.raceTab.selected	==		(TAB_MAP[ARR_BACK_TEAM]))
			{
				refreshIndex();
			}
			if(_needRefreshTab)
			{
				refreshTab();
				_needRefreshTab=false;
//				refreshIndex()
			}
//			if(ui.raceTab.selected	==	1)
//			{
//				refreshIndex();
//			}
			function add(arr:Array):void
			{
				if(index	==	-1)
				{
					arr.push(targetObj);
				}else
					if(arr[index]	&&	arr[index]	!=targetObj)
					{
						if(targetObj)
						{
							arr.splice(index,0,targetObj);
						}
					}
					else
					{
						arr[index]	=	targetObj;	
					}
			}
			function addALl():void
			{
				targetARr	=	findSameConfigId(PropertiesValue,_partnerRaces[ARR_ALL]);
				if(targetARr.length==0)
				{
					add(_partnerRaces[ARR_ALL]);
				}
			}
		}
		/**
		 *从服务器上读取属性设置到本地 
		 * @param objdata
		 * @param obj
		 * @return 
		 * 
		 */		
		private function combiObj(objdata:ObjectData,obj:Object):Object
		{
			var  dataObj:Object=objdata.Properties;
			for (var property:String in dataObj)
			{
				if (dataObj[property])
				{
					obj[property] = dataObj[property];
				}
			}
			return obj
		}
		/**
		 *仅仅用于归队 
		 * @param PropertiesName
		 * @param PropertiesValue
		 * @param data
		 * 
		 */		
		private function OnRemoveRetirePartner(PropertiesName:String,PropertiesValue:ViewObject,data:*):void
		{
			var id:int	=	PropertiesValue.GetPropertiesEx("ConfigID");
			var targetObj:Object	=	_nowConfdata[id];
			if(targetObj	==	null)
			{
//				_nowConfdata[id]=
				var allArr:Array	=	_partnerRaces[ARR_ALL];
				var targetARr:Array		=	findSameConfigId(PropertiesValue,allArr);
				for each (var i:Object in targetARr) 
				{
					var ind:int=allArr.indexOf(i)
//					allArr.splice(ind,1);
					_nowConfdata[i[PART_CONFIG_ID]]=i;
					//				 i[ARR_ALL]=ind;
				}
				targetObj=targetARr[0];
			}
			targetObj=combiObj(PropertiesValue,targetObj);
			var arr:Array	=	_partnerRaces[ARR_BACK_TEAM];
			if(!arr)
			{
				return
			}
			remove(arr);
			if(ui.raceTab.selected	==	(TAB_MAP[ARR_BACK_TEAM]))
			{
				refreshIndex();
			}
			function remove(targetArr:Array):int
			{
				if(targetArr&&targetArr.length)
				{
//					var target:Array	=	findSameConfigId(PropertiesValue,targetArr)
//					i = target;
					var ind:int=targetArr.indexOf(targetObj)
					if(ind!=-1)
					{
						targetArr.splice(ind,1);
					}
					return ind;
				}
				return -1;
			}
			
		}
		private function OnAddPartner(PropertiesName:String,PropertiesValue:ViewObject,data:*):void
		{
			_hasPartnerInvite=false;
			var index:int=/*transferGangToTabIndex*/(PropertiesValue.GetPropertiesEx(PART_GANG))
			var configid:int=PropertiesValue.GetPropertiesEx("ConfigID");
//			trace("PartnerInviteLogic.OnAddPartner(PropertiesName, PropertiesValue, data)",PropertiesValue);
			var targetARr:Array;
			if(!_nowPartnerArr[PropertiesName])
			{
				nowPartnerCount++;
			}
			_nowPartnerArr[PropertiesValue.ObjKey]=PropertiesValue;
			var allArr:Array	=	_partnerRaces[ARR_ALL];
			var iobj:Object=_nowConfdata[configid];
			if(!iobj)
			{
				 targetARr		=	findSameConfigId(PropertiesValue,allArr);
				 for each (var ii:Object in targetARr) 
				 {
					 var ind:int=allArr.indexOf(ii)
					 allArr.splice(ind,1);
					 _nowConfdata[ii[PART_CONFIG_ID]]=ii;
					 ii[ARR_ALL]=ind;
				 }
				 iobj	=	_nowConfdata[configid];
			}
			else
			{
				iobj[ARR_ALL]	=	remove(allArr)
			}
			var raceArr:Array		=	_partnerRaces[index];//ui.raceTab.dataProvider[index+3].data
			ind	=	remove(raceArr);
			if(!iobj)return 
			if(!raceArr||!raceArr.length)
				_needRefreshTab=true;
			iobj[ARR_RACE]	=	ind;
			var commendRefresh:Boolean=false;
			if(iobj[PART_COMMEND]	!=	"0"&&	iobj[PART_COMMEND])
			{
				var commendArr:Array=_partnerRaces[ARR_COMMEND];
				ind	=	remove(commendArr);
				commendRefresh=true;
//				targetARr[0][ARR_COMMEND]	=	ind;
			}
			else
			{
				iobj[ARR_COMMEND]	=	-1;
			}
//			trace("PartnerInviteLogic.OnAddPartner(PropertiesName, PropertiesValue, data)",targetARr[0][ARR_COMMEND]);
			if(ui.raceTab.selected	==	transferGangToTabIndex(index)	||ui.raceTab.selected	==	(TAB_MAP[ARR_ALL])||(commendRefresh&&ui.raceTab.selected	==	(TAB_MAP[ARR_COMMEND])))
			{
				refreshIndex();
			}
			if(_needRefreshTab)
			{
				refreshTab();
				_needRefreshTab=false;
//				refreshIndex()
			}
			function remove(targetArr:Array):int
			{
				if(targetArr&&targetArr.length)
				{
				var target:Array	=	findSameConfigId(PropertiesValue,targetArr);
					if(target[0])
					 iobj = target[0] 
						var ind:int=targetArr.indexOf(iobj)
//						trace("PartnerInviteLogic.remove(targetArr)",targetArr.indexOf(i));
						if(ind!=-1)
						{
							targetArr.splice(ind,1);
						}
					return ind;
				}
				return -1;
			}
		}
		private function findSameConfigId(viewObj:ViewObject,arr:Array):Array
		{
			var arrr:Array	=	arr.filter(arrfilterClosure);
//			if(!arrr||!arrr.length)
//			{
//					trace("begin",arr.forEach(function(indd:int,obbbj:Object,arr:Array):void{
//					trace(obbbj,arr[obbbj][PART_CONFIG_ID])
//				}),"Configid:",viewObj.GetPropertiesEx("ConfigID"))
//			}
			return arrr;
			function arrfilterClosure(item:*,index:int,arr:Array):Boolean
			{
//				trace("PartnerInviteLogic.arrfilterClosure(item, index, arr)",item[PART_CONFIG_ID],viewObj.GetPropertiesEx("ConfigID"),item[PART_CONFIG_ID]	==	viewObj.GetPropertiesEx("ConfigID"));
				if(item.hasOwnProperty(PART_CONFIG_ID))
				return item[PART_CONFIG_ID]		==	viewObj.GetPropertiesEx("ConfigID");
				trace("Error~~PartnerInviteLogic.arrfilterClosure(item, index, arr)",item,index,arr);
				return	false
			}
		}
		private function OnRemovePartner(PropertiesName:String,PropertiesValue:ViewObject,data:*):void
		{
			nowPartnerCount--;
			var index:int=/*transferGangToTabIndex*/(PropertiesValue.GetPropertiesEx(PART_GANG));
				//RACE_ARR.indexOf(PropertiesValue.GetPropertiesEx(PART_GANG)+1);
			_nowPartnerArr[PropertiesValue.ObjKey]=null;
			var allArr:Array=_partnerRaces[ARR_ALL];
			var targetObj:Object;
			var id:int=PropertiesValue.GetPropertiesEx("ConfigID");
			targetObj=_nowConfdata[id];
			if(targetObj)
			{
				var ind:int=targetObj[ARR_ALL]
//				trace("PartnerInviteLogic.OnRemovePartner(PropertiesName, PropertiesValue, data)",targetArr);
				_nowConfdata[id]	=	null;
				add(allArr)
				var raceArr:Array=_partnerRaces[index];/*ui.raceTab.dataProvider[index+3].data*/
				if(!raceArr||!raceArr.length)
					_needRefreshTab	=	true;
//				if(!raceArr[index])
//				{
//					raceArr[index]	=	[];
//				}
				ind	=	targetObj[ARR_RACE];
				add(raceArr);
				if(!_partnerRaces[ARR_COMMEND])
				{
					_partnerRaces[ARR_COMMEND]=[];
				}
				if(targetObj[PART_COMMEND])
				{
					var commendArr:Array=_partnerRaces[ARR_COMMEND];
					ind	=	targetObj[ARR_COMMEND];
					add(commendArr);
				}
			}
//			if(ui.raceTab.selected	==	index	||ui.raceTab.selected	==	0)
//			{
//				refreshIndex();
//			}
			function add(arr:Array):void
			{
				if(ind	==	-1)return ;
				if(ind>arr.length)
				{
					arr.push(ind);
				}
				else
				{
					if(arr[ind]	&&	arr[ind]	!=targetObj)
					{
						if(targetObj)
						{
							arr.splice(ind,0,targetObj);
						}
					}
					else
					{
						arr[ind]	=	targetObj;	
					}
				}
			}
		}
		
	}
}